package main

import (
	"log"
	"strings"
)
import "github.com/edwingeng/wuid/redis"

func  main()  {
	varr := []string{"app_id","chanel_id","shi"}
	// Setup
	g := wuid.NewWUID("default", nil)
	e := g.LoadH24FromRedis("118.24.238.198:16379", "", "wuid")
	if nil != e{
		log.Print(e.Error())
	}

	str := " not " + strings.Join(varr, ":0 not ") + ":0 not " + strings.Join(varr, ":\"\" not ") + ":\"\""
	log.Print(str)
	r := strings.NewReplacer("sheng", "region", "shi", "region")
	str = r.Replace(str)
	log.Print(str)
	having := " having " + strings.Join(varr, " is not null and ") + " is not null"
	log.Print(having)
	r = strings.NewReplacer("sheng is not null", "length(region) > 1", "shi is not null", "length(region) > 2 and substr(region,3,4) != '00'", "region is not null", "length(region) > 4 and substr(region,5,6) != '00'")
	having = r.Replace(having)
	log.Print(having)
}
